package com.jiepos.mpos.biz.review.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.jiepos.mpos.biz.affix.service.AppAffixInfService;
import com.jiepos.mpos.biz.customer.service.AppCustomerInfoService;
import com.jiepos.mpos.biz.customer.service.CustomBankcardInfoService;
import com.jiepos.mpos.biz.review.service.SettleAccountDoneService;
import com.jiepos.mpos.common.entity.MemReviewEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;
import com.jiepos.mpos.core.util.StringUtils;

/**
 * 
 * 结算信息已办事项管理
 * @ProjectName:  [mpos] 
 * @Package com.jiepos.mpos.biz.review.controller 
 * @author 张磊
 * @version 1.0
 * @since 2017年9月27日 上午11:31:30
 * @history（历次修订内容、修订人、修订时间等）
 * @UpdateRemark [说明本次修改内容]
 * @Copyright (c) 2017 江苏杰博实信息技术有限公司
 */
@Controller
@RequestMapping("settleaccountdone")
public class SettleAccDoneController extends BaseController{

	@Autowired
	private SettleAccountDoneService settleAccountDoneService;
	
	@Autowired
	private AppCustomerInfoService appCustomerInfoService;
	
	@Autowired
	private CustomBankcardInfoService customBankcardInfoService;
	
	@Autowired
	private AppAffixInfService appAffixInfService;
	/**
	 * 获取会员信息列表
	 * @param request
	 * @param response
	 * @param pagination
	 * @param memReviewEntity
	 * @return
	 */
	@RequestMapping("/getAccountDoneList.do")
	public ModelAndView getAccountDoneList(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination){

		ModelAndView model = new ModelAndView("/module/review/settleaccountdone/settleaccountdone_list");
		return super.getDetail(request, response, model);
	}
	
	/**
	 * 获取会员信息Json
	 * @param request
	 * @param response
	 * @param pagination
	 * @param memReviewEntity
	 * @return
	 */
	@RequestMapping("/getAccountDoneListJson.do")
	@ResponseBody
	public Map getAccountDoneListJson(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination,MemReviewEntity memReviewEntity){
		
		return settleAccountDoneService.getAccountDoneListJson(pagination,request,memReviewEntity);
	}
	
	@RequestMapping("/getAccDoneInfo.do")
	public ModelAndView  getAccDoneInfo(HttpServletRequest request, HttpServletResponse response, String bankcard_uuid ){
		
		ModelAndView model = new ModelAndView("/module/review/settleaccountdone/settleaccountdone_detail");
		model.addObject("bankcard_uuid",bankcard_uuid);
		return super.getDetail(request, response, model);
	}    
	
	/**
	 * 获取会员结算信息
	 * @param request
	 * @param response
	 * @param bankcard_uuid
	 * @return
	 */
	@RequestMapping("/getCommonAccDoneInfo.do")
	public ModelAndView getCommonAccInfo(HttpServletRequest request, HttpServletResponse response, String bankcard_uuid){
		ModelAndView model = new ModelAndView("/module/review/settleaccountreview/settleaccount_common_detail");
		
		if(!StringUtils.isEmpty(bankcard_uuid)){
			Map app_Custom_InfEntity = customBankcardInfoService.getCustomUUIDByUUID(bankcard_uuid);
			String custom_uuid = (String) app_Custom_InfEntity.get("custom_uuid");
			Map customInfEntity = appCustomerInfoService.getCustomerInfoByUUID(custom_uuid);
			Map appCustomBankOldEntity = customBankcardInfoService.getOldCustomBankcardInfo(bankcard_uuid);
			Map appCustomBankNewEntity = customBankcardInfoService.getNewestCustomBankcardInfo(bankcard_uuid);
			List<Map<String, Object>> oldPicList = appAffixInfService.getOldPic(custom_uuid,bankcard_uuid);
			List<Map<String, Object>> newPicList = appAffixInfService.getNewPic(custom_uuid,bankcard_uuid);
			
			model.addObject("customInfEntity",customInfEntity);
			model.addObject("appCustomBankOldEntity",appCustomBankOldEntity);
			model.addObject("appCustomBankNewEntity",appCustomBankNewEntity);
			model.addObject("oldPicList",oldPicList);
			model.addObject("newPicList",newPicList);
		}
		
		return super.getDetail(request, response, model);
	}
	
}
